Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-835

IgniteCache.lock is broken for PARTITIONED cache without near cache.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.8
    • cache

    Description

      Steps to reproduce:
      1) Go to GridCacheLockAbstractTest
      2) Add the test source below.
      3) Make sure to disable near cache (GridCacheLockAbstractTest.cacheConfiguration() -> setNearConfiguration(null)).
      4) Run GridCachePartitionedLockSelfTest.testLockReentrancy() and observe assertion failure.
      5) Enable near cache back and re-run the test. Observe that now it pass.

      public void testLockReentrancy() throws Throwable {
          for (int i = 10; i < 100; i++) {
              System.out.println("Key: " + i);
      
              final int i0 = i;
      
              final Lock lock = cache1.lock(i);
      
              lock.lockInterruptibly();
      
              try {
                  final AtomicReference<Throwable> err = new AtomicReference<>();
      
                  Thread t =  new Thread(new Runnable() {
                      @Override public void run() {
                          try {
                              assert !lock.tryLock();
                              assert !lock.tryLock(100, TimeUnit.MILLISECONDS);
      
                              assert !cache1.lock(i0).tryLock();
                              assert !cache1.lock(i0).tryLock(100, TimeUnit.MILLISECONDS);
                          }
                          catch (Throwable e) {
                              err.set(e);
                          }
                      }
                  });
      
                  t.start();
                  t.join();
      
                  if (err.get() != null)
                      throw err.get();
      
                  lock.lock();
                  lock.unlock();
      
                  t =  new Thread(new Runnable() {
                      @Override public void run() {
                          try {
                              assert !lock.tryLock();
                              assert !lock.tryLock(100, TimeUnit.MILLISECONDS);
      
                              assert !cache1.lock(i0).tryLock();
                              assert !cache1.lock(i0).tryLock(100, TimeUnit.MILLISECONDS);
                          }
                          catch (Throwable e) {
                              err.set(e);
                          }
                      }
                  });
      
                  t.start();
                  t.join();
      
                  if (err.get() != null)
                      throw err.get();
              }
              finally {
                  lock.unlock();
              }
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              sboikov Semen Boikov
              vozerov Vladimir Ozerov
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m